import {httpRequest} from '@/utils/http';
import {ElevatorTiringVO, ElevatorTiringForm, ElevatorTiringQuery} from '@/api/iot/elevatorTiring/types';

enum Api {
    root = '/iot/elevatorTiring',
    list = '/iot/elevatorTiring/list',
    starRescue = '/iot/elevatorTiring/starRescue',
    rescueSign = '/iot/elevatorTiring/rescueSign',
    rescueComplete = '/iot/elevatorTiring/rescueComplete',
    confirmComplete = '/iot/elevatorTiring/confirmComplete',
}


/**
 * 查询电梯困人管理列表
 * @param query
 * @returns {*}
 */
export function listElevatorTiring(query?: ElevatorTiringQuery) {
    return httpRequest.get<ElevatorTiringVO[]>({url: Api.list, data: query});
}

/**
 * 查询电梯困人管理详细
 * @param tiringId
 */
export const getElevatorTiring = (tiringId: string | number) => {
    return httpRequest.get<ElevatorTiringVO>({url: Api.root + '/' + tiringId});
}

/**
 * 新增电梯困人管理
 * @param data
 */
export const addElevatorTiring = (data: ElevatorTiringForm) => {
    return httpRequest.post({url: Api.root, data});
}

/**
 * 获取困人数量
 */
export function getElevatorTiringCount() {
    return httpRequest.get<number>({url: Api.root + '/getElevatorTiringCount'});
}

/**
 * 开始救援
 */
export function starRescue(data: ElevatorTiringForm) {
    return httpRequest.post({url: Api.starRescue, data});
}

/**
 * 救援签到
 */
export function rescueSign(data: ElevatorTiringForm) {
    return httpRequest.post({url: Api.rescueSign, data});
}

/**
 * 救援完成
 */
export function rescueComplete(data: ElevatorTiringForm) {
    return httpRequest.post({url: Api.rescueComplete, data});
}

/**
 * 确认救援完成
 */
export function confirmComplete(data: ElevatorTiringForm) {
    return httpRequest.post({url: Api.confirmComplete, data});
}